home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / mscfunct / com.doc < prev    next >
Text File  |  1987-05-08  |  2KB  |  82 lines

  1.       COM: port support functions for Microsoft C
  2.  
  3. #include <com.h>
  4.  
  5. char com_getc( port );
  6. int port;
  7.  
  8. int com_init( port, baud, parity, stop, length );
  9. int port, baud, parity, stop, length;
  10.  
  11. unsigned int com_putc( port, c );
  12. int port; char c;
  13.  
  14. int com_ready( port );
  15. int port;
  16.  
  17. int com_stat( port );
  18. int port;
  19.  
  20.  
  21. o Description
  22.  
  23. The com functions provide control over the serial ports of your PC.
  24.  
  25. The function com_getc waits until a character is present at the specified
  26. serial port, and it then inputs the character and returns it.
  27.  
  28. The function com_init sets the baud rate, parity, stop bits and word length
  29. of the specified serial port and returns the status word, as described
  30. below.
  31.  
  32. The function com_putc outputs a character to the specified serial port
  33. and returns the status word after attempting to send the character.
  34.  
  35. The function com_ready checks the serial port specified and returns a 1 if a
  36. character is waiting or a 0 if there is no input waiting.
  37.  
  38. The function com_stat returns the status word for the specified port.
  39.  
  40.  
  41.                  NOTES
  42.                  -----
  43.  
  44.     Status word bit assignments:
  45.     
  46.     bit    MASK    Meaning
  47.     ---    ----    -------
  48.      0    0x0001    Clear to Send has changed state
  49.      1    0x0002    Data Set Ready has changed state
  50.      2    0x0004    End of ringing pulse detector
  51.      3    0x0008    Carrier Detect signal has changed state
  52.      4    0x0010    Clear to Send signal
  53.      5    0x0020    Data Set Ready signal
  54.      6    0x0040    Ringing indicator
  55.      7    0x0080    Carrier Detect signal
  56.     
  57.      8    0x0100    Received data is ready
  58.      9    0x0200    Overrun error (previous character not read & a new
  59.             character has arrived)
  60.     10    0x0400    Parity error (in incoming data)
  61.     11    0x0800    Framing error (an incorrect start/stop bit was received)
  62.     12    0x1000    Break detect
  63.     13    0x2000    Transmitter holding register empty (ready for another character
  64.             to transmit)
  65.     14    0x4000    Transmitter shift register empty (not currently transmitting)
  66.     15    0x8000    Time-out error
  67.     
  68.     
  69.     
  70.     com_init values for baud, parity, stop, and length
  71.  
  72.     baud: 0 = 110 baud;  1 = 150 baud;  2 = 300 baud;  3 = 600 baud;
  73.           4 = 1200 baud; 5 = 2400 baud; 6 = 4800 baud; 7 = 9600 baud.
  74.     
  75.     parity: 0 = no parity; 1 = odd parity; 2 = no parity; 3 = even parity.
  76.     
  77.     stop: 0 = 1 stop bit; 1 = 2 stop bits.
  78.     
  79.     length: 0 = 5-bit words; 1 = 6-bit words; 2 = 7-bit words; 3 = 8-bit words.
  80.     
  81.  
  82.